<template>
	<view>
		<view class="searchCss">
			<view class="">
				<input v-model="bookName" style="width: 500upx;border: 1upx solid #8F8F94; border-radius: 16upx;padding: 10upx;" class="uni-input" focus placeholder="请输入书名" />
			</view>
			<view class="">
				<button type="default" size="mini" @click="searchBtn()">搜索</button>
			</view>
		</view>
	
		<view class="">
			<view class="zhan" v-for="items in bookList">
				<view class="">
					<image :src="items.bookImg" style="width: 200upx;height: 220upx;"></image>
				</view>
				<view style="display: flex;flex-direction: column;line-height: 47upx;">
					<view class="">
						{{items.bookName}}
					</view>
					<view style="display: flex;flex-direction: row;">
						<!-- <view style="margin-right: 30upx;">
							状态: <span v-if="items.bookState==0">未借阅</span>
							<span v-if="items.bookState==1">已借阅</span>
						</view> -->
						<view class="">
							位置: {{items.shelfNum}}
						</view>
					</view>
					<view class="">
						上架时间: {{items.createDate}}
					</view>
					<!-- <view>
						借阅 :
						<span @click="jieyue(items.id,items.bookName)" v-if="items.bookState==0" style="color: #ff5500;"> 可借阅</span>
						<span v-if="items.bookState==1" style="color: #8F8F94;"> 已借阅</span>
					</view> -->
				</view>
			</view>

		</view>
	</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				bookList: [],
				bookName: ''
			}
		},
		onLoad() {
			
		},
		methods: {
			searchBtn() {
				var _this = this
				uni.request({
					url: _this.serverUrl + "renren/bookmanager/list3",
					data:{
						key:_this.bookName
					},
					success(res) {
						_this.bookList = res.data.page.list
					}
				})
			},
			jieyue(id,name) {
			
				var _this=this
				uni.request({
					url: _this.serverUrl + "renren/bookmanager/update",
					method:'POST',
					data:{
						id:id,
						bookState:1
					},
					success(res) {
						uni.showToast({
							title:'借阅成功',
							icon:'none'
						})
						_this.initData()
						_this.tushujie(id,name)
						
					}
				})
				
			},
			tushujie(id,name){
				var _this=this
				var usersName = uni.getStorageSync('usersName')
				var usersId = uni.getStorageSync('usersId')
				uni.request({
					url:_this.serverUrl+'renren/bookborrow/save',
					method:'POST',
					data:{
						userId:usersId,
						bookId:id,
						bookName:name,
						bookState:1
					},success(res) {
						debugger
					}
				})
				
			}
		
		
		}
	}
</script>

<style>
	.searchCss{
		display: flex;
		flex-direction: row;
		justify-content: space-around;
		align-items: center;
		align-content: center;
		margin: 20upx 20upx 20upx 10upx;
	}
	.zhan {
		margin: 20upx 40upx 20upx 40upx;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		font-size: 27upx;
		border-bottom: 1upx dashed #555555;
		padding: 10upx;
	}

	.kec1 {
		display: flex;
		flex-direction: column;
		justify-items: center;
		align-items: center;
		border: 1upx solid #555555;
		padding: 10upx;
		border-radius: 16upx;
	}

	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
